<?php 
namespace app\Index\controller;
use think\Controller;
use think\Request;
use app\index\model\Operation;
class Operationc extends Base
{
    //发布公告
    public function put_notice(){
        if(Request::instance()->isPost()){
            $worker = input("post.worker");
            $content = input("post.cont");

            $operation = new Operation();
            $data = $operation -> put_notice($content, $worker);
            if($data >= 0){
                return json(array("status"=>1, "message"=>"操作成功！", "data"=>$data));
            }else{
                return json(array("status"=>0, "message"=>"操作失败！", "data"=>[]));
            }
        }
    }

    //通道维护
    public function change_channel(){
        if(Request::instance()->isPost()){
            $operate = input("post.operation");
            $chan = explode("_", $operate);
            $channel = $chan[0];
            $op = $chan[1];
            switch($op){
                case "start":
                    $status = 1;
                    break;
                case "stop":
                    $status = 0;
                    break;
                default:
                    $status = -1;
                    break;
            }
            if($status >= 0){
                $operation = new Operation();
                $data = $operation -> change_channel($channel, $status);
                if($data >= 0){
                    return json(array("status"=>1, "message"=>"操作成功！", "data"=>$data));
                }else{
                    return json(array("status"=>0, "message"=>"操作失败！", "data"=>[]));
                }
            }else{
                return json(array("status"=>0, "message"=>"操作非法！", "data"=>[]));
            }
        }
    }
}